local fenzhi = fk.CreateSkill{
  name = "lingling__fenzhi",
}

Fk:loadTranslationTable{
  ["lingling__fenzhi"] = "分治",
  [":lingling__fenzhi"] = "每回合限一次，你可以将出牌阶段改为摸牌阶段执行，或将摸牌阶段改为出牌阶段执行。",

  ["#lingling__fenzhi-invoke"] = "分治：你可以将即将进入的“%arg”改为“%arg2”",
}

fenzhi:addEffect(fk.EventPhaseChanging, {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(fenzhi.name) and
      (data.phase == Player.Draw or data.phase == Player.Play) and
      player:usedSkillTimes(fenzhi.name, Player.HistoryTurn) == 0
  end,
  on_cost = function(self, event, target, player, data)
    local arg, arg2
    if data.phase == Player.Draw then
      arg = "phase_draw"
      arg2 = "phase_play"
    else
      arg = "phase_play"
      arg2 = "phase_draw"
    end
    return player.room:askToSkillInvoke(player, {skill_name = self.name, prompt = "#lingling__fenzhi-invoke:::"..arg..":"..arg2})
  end,
  on_use = function(self, event, target, player, data)
    data.phase = (data.phase == Player.Draw) and Player.Play or Player.Draw
  end,
})

return fenzhi
